Home

Operator Usage

Name

patch-map

Description

patch-map[input-width, input-height, output-width, output-height, op] input-sp
patch-map[input-width, input-height, skip-size, output-width, output-height, op] input-sp
convert an input superposition into a rectangular grid with the given input-width
then sub-divide that grid into "patches" of size output-width * output-height
then feed those patches to the passed in operator: op
the hope is that patch-map[] will be useful for MNIST
if skip-size is defined, then skip patches
eg, if skip-size == 1, then don't skip any patches
if skip-size == 2, then skip every second patch
if skip-size == 3, then only process 1 in 3 patches, and so on


Examples

-- first, define an appropriate superposition:
the |sp> => rank (|0: 0> .. |3: 3>)

-- now visualize this as a patch:
display-patch[4,4] the |sp>
    1  2  3  4
    5  6  7  8
    9  10 11 12
    13 14 15 16
    |patch>

-- now apply patch-map[], and use sprint as the operator:
patch-map[4, 4, 2, 2, sprint] the |sp>
    |0: 0> + 2|0: 1> + 5|1: 0> + 6|1: 1>
    2|0: 0> + 3|0: 1> + 6|1: 0> + 7|1: 1>
    3|0: 0> + 4|0: 1> + 7|1: 0> + 8|1: 1>
    5|0: 0> + 6|0: 1> + 9|1: 0> + 10|1: 1>
    6|0: 0> + 7|0: 1> + 10|1: 0> + 11|1: 1>
    7|0: 0> + 8|0: 1> + 11|1: 0> + 12|1: 1>
    9|0: 0> + 10|0: 1> + 13|1: 0> + 14|1: 1>
    10|0: 0> + 11|0: 1> + 14|1: 0> + 15|1: 1>
    11|0: 0> + 12|0: 1> + 15|1: 0> + 16|1: 1>
    9|patches>

-- now the skip-size version, here, use skip-size == 2:
patch-map[4, 4, 2, 2, 2, sprint] the |sp>
    |0: 0> + 2|0: 1> + 5|1: 0> + 6|1: 1>
    3|0: 0> + 4|0: 1> + 7|1: 0> + 8|1: 1>
    9|0: 0> + 10|0: 1> + 13|1: 0> + 14|1: 1>
    11|0: 0> + 12|0: 1> + 15|1: 0> + 16|1: 1>
    4|patches>

-- now the skip-size version again,
-- this time visualize the resulting superpositions
-- first, define this print 2*2 patch wrapper operator:
print-patch-2 (*) #=>
    print |---------->
    display-patch[2, 2] |__self>

-- now invoke patch-map:
patch-map[4, 4, 2, 2, 2, print-patch-2] the |sp>
    ----------
    1  2
    5  6
    ----------
    3  4
    7  8
    ----------
    9  10
    13 14
    ----------
    11 12
    15 16
    4|patches>

See also

Operator type

sequence compound context